<template>
  <el-config-provider :locale="locale" :size="size">
    <!-- 开启水印 -->
    <el-watermark
        v-if="watermarkEnabled"
        :font="{ color: fontColor}"
        :content="[watermarkContent,watermarkContent2]"
        class="wh-full"
        :zIndex="9999"
        :width="140"
    >
      <router-view/>
    </el-watermark>
    <!-- 关闭水印 -->
    <router-view v-else/>
  </el-config-provider>
</template>

<script setup lang="ts">
import {useAppStore, useSettingsStore, useUserStore} from "@/store";
import defaultSettings from "@/settings";
import {ThemeEnum} from "@/enums/ThemeEnum";
import {SizeEnum} from "@/enums/SizeEnum";
import BatchImportExportConfigAPI from "@/api/batchImportExportConfig";

const appStore = useAppStore();
const settingsStore = useSettingsStore();
const userStore = useUserStore();

const locale = computed(() => appStore.locale);
const size = computed(() => appStore.size as SizeEnum);
// const watermarkEnabled = computed(() => settingsStore.watermarkEnabled);
const watermarkEnabled = true;
const watermarkContent = computed(() => userStore.user.username ?? defaultSettings.watermarkContent);
const watermarkContent2 = computed(() => userStore.user.nickname ?? defaultSettings.watermarkContent);

// 明亮/暗黑主题水印字体颜色适配
const fontColor = computed(() => {
  return settingsStore.theme === ThemeEnum.DARK
      ? "rgba(255, 255, 255, .15)"
      : "rgba(0, 0, 0, .15)";
});
</script>
